package com.topevery.yllhdemo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.topevery.yllhdemo.model.UmEvent;
import com.topevery.yllhdemo.service.UmEventService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/evt")
public class UmEventController {

    @Autowired
    private UmEventService umEventService;

    @GetMapping("/getUmEventById")
    public UmEvent getUmEventById(Integer evtId) {
        return umEventService.getById(evtId);
    }

    @GetMapping("/getUmEventByPage")
    public IPage<UmEvent> getUmEventByPage(Integer pageIndex) {
        Page<UmEvent> page = new Page<UmEvent>(pageIndex, 5);

        IPage<UmEvent> ret =    umEventService.selectUserPage(page,0);

        return ret;
    }


    @GetMapping("/getUmEventByPage2")
    public IPage<UmEvent> getUmEventByPage2(Integer pageIndex) {
        Page<UmEvent> page = new Page<UmEvent>(pageIndex, 5);

        Map<String,Object> param = new HashMap<>();
        //param.put("title","%盘锦城管2%");
        param.put("status",0);
        IPage<UmEvent> ret =    umEventService.selectPage2(page,param);

        return ret;
    }
}
